<!--
 * @Author: C.
 * @Date: 2023-01-29 15:48:07
-->
<template>
  <PageWrapper
    :title="t('routes.process.menu.editCraftTemplate')"
    :contentStyle="{ paddingBottom: '100px' }"
  >
    <Card title="模板信息" :bordered="false">
      <BasicForm @register="register" @fieldValueChange="fieldValueChange" />
    </Card>
    <template #rightFooter>
      <a-button type="primary" @click="submitAll"> {{ t('common.saveText') }} </a-button>
    </template>
  </PageWrapper>
</template>
<script lang="ts" setup name="craftTemplate_edit">
  import { BasicForm, useForm } from '/@/components/Form';
  import { PageWrapper } from '/@/components/Page';
  import { useAppRouter } from '/~/hooks/help/useAppRouter';
  import { Card } from 'ant-design-vue';
  import { formSchemas } from './config';
  import { useI18n } from '/@/hooks/web/useI18n';

  const { closeTo } = useAppRouter();
  const { t } = useI18n();
  const [register, { validateFields }] = useForm({
    layout: 'vertical',
    baseColProps: {
      span: 8,
    },
    rowProps: {
      gutter: 20,
    },
    schemas: formSchemas,
    showActionButtonGroup: false,
  });

  async function submitAll() {
    try {
      await validateFields();
      closeTo({
        name: 'craftTemplate_detail',
      });
    } catch (error) {
      console.log('not passing', error);
    }
  }
  function fieldValueChange(key, value) {
    console.log(key, value);
  }
</script>
